package com.example.teachingSystem.controller;

import com.example.teachingSystem.pojo.form.BasePageQuery;
import com.example.teachingSystem.pojo.form.TS.AddStuForm;
import com.example.teachingSystem.pojo.form.TS.UpdateStuForm;
import com.example.teachingSystem.pojo.vo.StudentInfoVo;
import com.example.teachingSystem.service.StudentService;
import com.example.teachingSystem.utils.result.PageResult;
import com.example.teachingSystem.utils.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/stu")
@Tag(name="学生管理模块")
public class StudentController {

    @Autowired
    StudentService studentService;


    @PostMapping("/addStu")
    @Operation(summary = "添加学生",security = {@SecurityRequirement(name = "Authorization")})
    public Result<String> adminAddStudent(@RequestBody AddStuForm addStuForm){
        return studentService.adminAddStudent(addStuForm);
    }


    @DeleteMapping("/deleteStu/{stuId}")
    @Operation(summary = "删除学生",security = {@SecurityRequirement(name = "Authorization")})
    public Result<String> adminDeleteStudent(@PathVariable Long stuId){
        return studentService.adminDeleteStudent(stuId);
    }

    @GetMapping("/getById/{stuId}")
    @Operation(summary = "通过id获取学生信息",security = {@SecurityRequirement(name = "Authorization")})
    public Result<StudentInfoVo>getStudentInfoById(@PathVariable Long stuId){
        return studentService.getStudentById(stuId);
    }


    @GetMapping("/getAllStu")
    @Operation(summary = "获取学生列表",security = {@SecurityRequirement(name = "Authorization")})
    public PageResult<StudentInfoVo> adminGetStudent(@ParameterObject BasePageQuery basePageQuery){
        return studentService.adminGetStudent(basePageQuery);
    }


    @PostMapping("/updateStu")
    @Operation(summary = "修改学生",security = {@SecurityRequirement(name = "Authorization")})
    public Result<String> adminUpadeStudent(@RequestBody UpdateStuForm updateStuForm){
        return studentService.adminUpadeStudent(updateStuForm);
    }
}
